/* eslint valid-jsdoc: "off" */

'use strict';
const path = require('path')
const fs = require('fs')


/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
    /**
     * built-in config
     * @type {Egg.EggAppConfig}
     **/
    const config = exports = {};

    // use for cookie sign key, should change to your own and keep security
    config.keys = appInfo.name + '_1597544837182_284';

    // add your middleware config here
    config.middleware = ['errorHandler', 'token'];

    // add your user config here
    const userConfig = {
        // myAppName: 'egg',
    };

    config.errorHandler = {
        // enable: true, // 中间件开启配置
        match: '/', // 设置请求中间件的请求路由
        // ignore: '', // 设置不经过这个中间件的请求路由
    };

    config.cluster = {
        listen: {
            port: 8040,
            hostname: '0.0.0.0',
        }
    }

    config.redis = {
        client: {
            port: 6379,          // Redis port
            host: '127.0.0.1',   // Redis host
            password: '',
            db: 0,
        },
    }

    config.multipart = {
        fileSize: '500mb',
        mode: 'file',
        fileExtensions: ['', '.*', '.pdf', '.doc', '.docx', '.xls', '.xlsx', '.accdb', '.pptx', '.txt'], // 扩展几种上传的文件格式
    };

    config.mail = {
        from: '',
    }

    config.security = {
        csrf: {
            enable: false
        }
    }

    config.bodyParser = {
        enable: true,
        formLimit: '50mb',
        jsonLimit: '5mb',
        textLimit: '5mb',
        queryString: {
            arrayLimit: 20000,
        }
    }

    config.logger = {
        level: 'DEBUG',
        consoleLevel: 'DEBUG',
        dir: path.join(__dirname, '../logs/'),
    };


    config.mysql = {
        //database configuration
        client: {
            //host
            host: '127.0.0.1',
            //port
            port: '3306',
            //username
            user: 'root',
            //password
            password: 'tiger',
            //database
            database: 'courseDB',
            charset: "utf8mb4"

        },
        //load into app,default is open //加载到应用程序，默认为打开
        app: true,
        //load into agent,default is close //加载到代理中，默认值为“关闭”
        agent: false,
    };


    config.miniprogramState = 'trial'//developer为开发版；trial为体验版；formal为正式版；默认为正式版

    config.WXGZH = {//公众号发送模版消息配置信息
        openIds:[//接收者的openid
            {value:'ow4Ac69A06gAYy84GwWzPqZneTPM',text:'亚男'},
            {value:'ow4Ac6xD7Cvf4rzuvShsVpw8IQr8',text:'墨白'},
            {value:'ow4Ac68bQvQts-72NhXpGFTFcjjM',text:'老师'},
            {value:'ow4Ac65Vrr3QNVBT3inSS1k3tB9A',text:'石头'}
        ],
        domainJump:'https://dev.06b5375e442c5f2419610bf0508f7d027726195c.pachongpaipai.com'//跳转地址
    };

    return {
        ...config,
        ...userConfig,
    };
};
